package tmall.framework.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * 线程池的创建
 */
@Configuration
public class ThreadPoolConfigurer {

    private int coreThreadSize;
    private int maxThreadSize;
    private long keepAliveTime;
    private int queueCapacity;


     public ExecutorService executorService(){
        BlockingQueue workQueue = new ArrayBlockingQueue(queueCapacity);
        ThreadPoolExecutor executorService = new ThreadPoolExecutor(coreThreadSize,maxThreadSize,keepAliveTime, TimeUnit.SECONDS,workQueue);
        return executorService;
    }

}
